package org.cbg.panel;

import java.awt.Dimension;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.io.IOException;

import javax.swing.JPanel;

import org.cbg.bean.SearchGoodsBean;
import org.cbg.btn.TrslationBtn;
import org.come.socket.Agreement;
import org.come.socket.SendMessageUntil;
import org.come.until.CutButtonImage;
import org.come.until.GsonUtil;



/**
 * 我要卖面板
 * 
 * @author Administrator
 * 
 */
public class TraslationWantSentJpanel extends JPanel {
    // 卡片布局
    private TraslationWantSendCardJpanel traslationWantSendCardJpanel;
    /**
     * 寄售商品shoumaishangpin<br>
     * 寄售金钱jishoujinqian<br>
     * 已寄售品yijishoupin<br>
     */
    private TrslationBtn shoumaishangpin, jishoujinqian, yijishoupin;

    public TraslationWantSentJpanel() {
        this.setPreferredSize(new Dimension(760, 460));
        this.setOpaque(false);
        this.setLayout(null);
        traslationWantSendCardJpanel = new TraslationWantSendCardJpanel();
        this.add(traslationWantSendCardJpanel);

        shoumaishangpin = new TrslationBtn("inkImg/number/b4/M01.png", 1);
        jishoujinqian = new TrslationBtn("inkImg/number/b4/B02a.png", 1);
        yijishoupin = new TrslationBtn("inkImg/number/b4/M02a.png", 1);

        shoumaishangpin.setBounds(5, 2, 64, 31);
        jishoujinqian.setBounds(5+65, 2, 83, 31);
        yijishoupin.setBounds(5+65+83, 2, 83, 31);

        this.add(shoumaishangpin);
        this.add(jishoujinqian);
        this.add(yijishoupin);
        yijishoupin.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                // TODO Auto-generated method stub
                try {
                    shoumaishangpin.setIcons(CutButtonImage.cuts("inkImg/number/b4/M01a.png"));
                    jishoujinqian.setIcons(CutButtonImage.cuts("inkImg/number/b4/B02a.png"));
                    yijishoupin.setIcons(CutButtonImage.cuts("inkImg/number/b4/M02.png"));
                } catch (Exception e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }

                /**
                 *
                 * 将搜索条件上传服务器操作得到数据 1、获取当前角色ID 2、初始化SearchGoodsBean对象
                 * 3、添加数据（貌似还缺少角色ID）到SearchGoodsBean对象 4、转换为对应的json对象 5、发送给服务器
                 */

                SearchGoodsBean searchGoodsBean = new SearchGoodsBean();
                searchGoodsBean.setPageNum(1);
                searchGoodsBean.setSaletype(1);
                searchGoodsBean.setSalename("");
                String sendmes = Agreement.getAgreement().searchMyWaresAgreement(
                        GsonUtil.getGsonUtil().getgson().toJson(searchGoodsBean));
                SendMessageUntil.toServer(sendmes);

                /**
                 * 展示已寄售品的面板（后面需要注释）
                 */
                traslationWantSendCardJpanel.getVcarCardLayout().show(traslationWantSendCardJpanel, "yijishoupin");
            }
        });
        jishoujinqian.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                try {
                    shoumaishangpin.setIcons(CutButtonImage.cuts("inkImg/number/b4/M01a.png"));
                    jishoujinqian.setIcons(CutButtonImage.cuts("inkImg/number/b4/B02.png"));
                    yijishoupin.setIcons(CutButtonImage.cuts("inkImg/number/b4/M02a.png"));
                } catch (Exception e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
                traslationWantSendCardJpanel.getVcarCardLayout().show(traslationWantSendCardJpanel, "jishoujinqian");
            }
        });
        shoumaishangpin.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                try {
                    shoumaishangpin.setIcons(CutButtonImage.cuts("inkImg/number/b4/M01.png"));
                    jishoujinqian.setIcons(CutButtonImage.cuts("inkImg/number/b4/B02a.png"));
                    yijishoupin.setIcons(CutButtonImage.cuts("inkImg/number/b4/M02a.png"));
                } catch (Exception e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
                traslationWantSendCardJpanel.getVcarCardLayout().show(traslationWantSendCardJpanel, "jishoushangpin");
            }
        });
    }

    public TraslationWantSendCardJpanel getTraslationWantSendCardJpanel() {
        return traslationWantSendCardJpanel;
    }

    public void setTraslationWantSendCardJpanel(TraslationWantSendCardJpanel traslationWantSendCardJpanel) {
        this.traslationWantSendCardJpanel = traslationWantSendCardJpanel;
    }


}
